using UnityEngine;

public class AttributeInfo : MonoBehaviour
{
	public PlayerStatsManager.AttributeType attrType;

	public UILabel level;

	public BarSliderControl trainingSlider;

	private bool hasUpdatedSlider;

	private void OnEnable()
	{
		PlayerStats playerStats = GGPlayerSettings.instance.statsManager.playerStats;
		float attributeValue = playerStats.GetAttributeValue((int)attrType);
		UITools.ChangeText(level, ((int)attributeValue).ToString());
		hasUpdatedSlider = false;
	}

	private void Update()
	{
		if (!hasUpdatedSlider)
		{
			UpdateSlider();
			hasUpdatedSlider = true;
		}
	}

	private void UpdateSlider()
	{
		PlayerStats playerStats = GGPlayerSettings.instance.statsManager.playerStats;
		float attributeValue = playerStats.GetAttributeValue((int)attrType);
		float progress = attributeValue - (float)(int)attributeValue;
		trainingSlider.UpdateSlider(progress);
	}

	public void OnSelectTraining()
	{
		TableTennisMainNavigation tableTennisMainNavigation = NavigationManager.instance as TableTennisMainNavigation;
		tableTennisMainNavigation.PushTraining(attrType);
	}
}
